Ext.define('AmpleHarvest.views.generalscare.main',
{
    extend          : 'Ext.panel.Panel',
    alias           : 'widget.ampleharvest-views-generalscare-main',
    requires        :
    [
            'AmpleHarvest.views.contentSection.content',
            'AmpleHarvest.objects.counter.main'
            
    ],
    // TODO: add classification handling using the following event
//  bubbleEvents    :
//  [
//      'doclassificationchange'
//  ],
    anchor          : '100% 100%',
    border			: 0,
	bubbleEvents	:
		[
			'doclassificationchange'
		],
    layout			:
	{
		type	: 'hbox',
		align	: 'stretch'
	},
    listeners       :
    {
    	handleCounterResponse : function(obj_data)
    	{
    		obj_data.ajaxProperties.config.obj_response_tgt.fireEvent('loadData', obj_data, this);
    	},
    	
    	reportContentClass	: function(str_contentClass)
    	{
        	this.fireEvent(
					AmpleHarvest.layout.cLayout.C_STR_EVENT_CLASSIFICATION_CHANGE,
					str_contentClass
			)
    	}
    },
    
    initComponent   : function()
    {
//    	this.on('afterrender', this.fireEvent('doclassificationchange', 'UNCLASSIFIED'));
    	
    	
    	this.m_obj_counter = Ext.create('AmpleHarvest.objects.counter.main',
    			{
    				str_data_source : '/solr-gs-base/app/count',
    				AHcaller		: this,
    				flex			: 1,
    				arr_tpl 		: [
    				        		   	'<div align="center" class="counter-background">',
			   		                    '<div><span class="counter-title">Processed Files</span></div>',	   
			   		        			'<div><span class="counter-value">{totalCount}</span></div>',
			   		        			'</div>'
			   		         	    ]
    			});
    	
    	this.m_obj_files = Ext.create('AmpleHarvest.objects.counter.main',
    			{
    				str_data_source : '/solr-gs-base/file/count',
    				AHcaller		: this,
    				flex			: 1,
    				arr_tpl 		: [
			   		                    '<div align="center" class="counter-background">',
			   		                    '<div><span class="counter-title">Processed Files</span></div>',	   
			   		        			'<div><span class="counter-value">{totalCount}</span></div>',
			   		        			'</div>'
			   		         	    ]
    			});
    	
    	this.m_obj_Panel_count = Ext.create('Ext.panel.Panel',
    			{
		    		flex	: 1,
		    		border	: 0,
					layout			:
					{
						type	: 'vbox',
						align	: 'stretch'
					},
					items	: [
					     	   this.m_obj_counter,
					     	   this.m_obj_files
					     	   ]
    			})
    	
    	    	
    	this.m_obj_list = Ext.create('AmpleHarvest.objects.basicList.basicList',
    			{
    				str_data_source : '/solr-gs-base/app/sources',
    				title			: "All Sources",
    				AHcaller		: this,
    				flex			: 7,
    				store			: Ext.create('AmpleHarvest.DATA.Store.genericGSCollection'),
    				columns	: [
 					          { header: 'Name', 		dataIndex: 'name', 		flex: 1 },
 					          { header: 'Count', 		dataIndex: 'apps', 		flex: 1 }
 					      ],
    			});
    	
//    	this.m_obj_list.store = Ext.create('AmpleHarvest.DATA.Store.genericGSCollection');
    			
    	this.m_obj_Panel = Ext.create('Ext.panel.Panel',
    			{
    				flex	: 1,
    				border	: 0,
    				layout			:
    				{
    					type	: 'vbox',
    					align	: 'stretch'
    				},
    				items	: [
    				     	   this.m_obj_Panel_count,
    				     	   this.m_obj_list
    				     	   ]
    			});
    	
    	this.m_obj_content = Ext.create('AmpleHarvest.views.contentSection.content',
    			{
    				flex			: 4,
    				classification	: 'UNCLASSIFIED//FOR OFFICIAL USE ONLY'
    			});

        this.items =
        [
         		this.m_obj_Panel,
                this.m_obj_content
        ]
        this.callParent();
        
//        this.on("beforerender", console.log(this.ownerCt), this);
    }
});


